package com.nowcoder.code.hjnc;

import java.util.Scanner;

public class HJ2 {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.nextLine();
        String s2 = scanner.nextLine();
        System.out.println(test(s1, s2));
    }

    public static int test(String s1, String s2) {
        char min = s2.toUpperCase().charAt(0);
        char max = s2.toLowerCase().charAt(0);
        int result = 0;
        for (int i = 0; i < s1.length(); i++) {
            char tmp = s1.charAt(i);
            if (tmp == min || tmp == max) {
                result++;
            }
        }
        return result;
    }


}
